#pragma once
#include <ctime>
enum LogLevel
{
    INFO,
    DEBUG,
    ERROR
};
enum LogLevel defaultLevel = DEBUG;//创建并初始化默认日志等级，低于该等级的日志将不会被打印

#define LOG(level, format, ...) do{\
        if(level < defaultLevel) break;/*如果log等级小于默认等级将不打印*/\
        time_t t = time(nullptr);\
        struct tm* ltm = localtime(&t);\
        char tmp[32] = {0};\
        strftime(tmp, 31, "%H:%M:%S", ltm);/*这里的31是为了最后一位留一个\0*/\
        fprintf(stdout, "[%p %s %s:%d] " format "\n", (void*)pthread_self(), tmp, __FILE__, __LINE__, ##__VA_ARGS__);\
    }while(0)

#define INFO_LOG(fomat, ...) LOG(INFO, fomat, ##__VA_ARGS__)
#define DEBUG_LOG(fomat, ...) LOG(DEBUG, fomat, ##__VA_ARGS__)
#define ERROR_LOG(fomat, ...) LOG(ERROR, fomat, ##__VA_ARGS__)
